<?php

namespace App\Http\ViewComposers;
use App\Models\Navigation;
use App\Models\Region;
use App\Models\Site;
use Illuminate\Http\Request;
use Illuminate\View\View;
class BaseInfoComposer
{
    public function compose(View $view)
    {
        // 模板公用导航数据
        $navigation = Navigation::with('childs')->where('parent_id',0)->where('status','T')->orderBy('sort','asc')->take(5)->get()->toArray();
        // 城市切换信息
        $area = Region::where('parent_id',0)->get(['id'])->toArray();
        $city = Region::whereIn('parent_id',$area)->get(['id','name','longitude','latitude']);
        // 站点配置信息
        $web = Site::get();
        $site = [];
        foreach ($web as $w){
            $site[$w['key']] = $w['value'] ;
        }
        $view->with([
            'navigation'  =>  $navigation,
            'site' => $site,
            'city' => $city
        ]);
    }
}